package br.com.intelsys.iflow.jbpm;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;

/**
 * Encapsula um processo BPM baseado no jBPM da JBOSS.
 * 
 * @author Patrick Givisiez
 *
 */

public class IFlowJbpm extends IFlowJbpmWrapper {
	private static final Log log = LogFactory.getLog(IFlowJbpm.class);

	/**
	 * Cria um novo contexto do JBPM caso ja nao esteja criado.
	 * 
	 * @return true se criado com sucesso
	 */
	protected boolean openContext() {
		if (this.jbpmContext == null) {
			log.debug("Criando um contexto para o jBPM");
			JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
			jbpmContext = jbpmConfiguration.createJbpmContext();
		}
		return(this.jbpmContext != null);
	}

}
